 
 import moment from 'moment'
 export const ModelMixins = {
     data(){
         return {
          //加载效果
          loading: false,
          // 日期显示
          yearPickShow: false,
         }
     },
     watch: {
       // 转疑点跳转回来解析
      $route: {
        handler: function (to) {
          if (Object.keys(to.query).length) {
            this.disableMixinCreated = true
            console.log(to.query)
            this.queryParam = Object.assign(this.queryParam, to.query)
            this.$nextTick(() => {
              this.onSearch()
            })
          } 
        },
        immediate: true,
      },
    },
     methods:{
        mergeCells(data, key, target) {
            //判断遍历数据是否为数组 
            if (!Array.isArray(data)) return 1
            data = data.map((_) => _[key]) // 只取出筛选项
            let preValue = data[0]
            const res = [[preValue]] // 放进二维数组里
            let index = 0 // 二维数组下标
            for (let i = 1; i < data.length; i++) {
              if (data[i] === preValue) {
                // 相同放进二维数组
                res[index].push(data[i])
              } else {
                // 不相同二维数组下标+1
                index += 1
                res[index] = []
                res[index].push(data[i])
                preValue = data[i]
              }
            }
            const arr = []
            res.forEach((_) => {
              const len = _.length
              for (let i = 0; i < len; i++) {
                arr.push(i === 0 ? len : 0)
              }
            })
            return arr[target]
          },
          mergeCol(text,key,record){
            let colSpan=1;
            // 当前列和其他对比如果有相同的值，就合并 仅限文字（数字不可用）
            for (const key in record) {
              if (Object.hasOwnProperty.call(row, key)) {
                 if(row[key]==text) colSpan++;
              }
            }
            return colSpan;
          },
    // 弹出日历和关闭日历的回调
    handleOpenChange(status) {
      this.yearPickShow = status
    },
    handlePanelChange(value) {
      console.log(value)
      this.yearPickShow = false
      this.queryParam.yearNum = moment(value).format('YYYY')
    },
    handleToYD(record) {
      if (this.dataSource.length) {
        const { startTime = '', endTime = '' } = this.queryParam
        let ydnr = undefined
        if (record) {
          ydnr = `【科目代码：${record.subjectCode}】【科目名称：${record.subjectName}】`
        }
        let time = `【${startTime}～${endTime}】【科目余额表】`
        this.addYd(this.queryParam, ydnr, time)
      } else {
        this.$message.error('空数据不能新建疑点')
      }
    },
     }
 }